<%@page import="com.tesam.gedeon.entity.SystemUser"%>
<%@page import="org.springframework.web.servlet.ModelAndView"%>
<%@page import="java.util.Map"%>
<%@ page session="true"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="t"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%> 
 
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> 

<!DOCTYPE html>
<html>
    <head>
        <%@include file="../../template/estilos.jsp"%>
<%@include file="../../template/script.jsp" %>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
   <body class="page-header-fixed">
 
  
     <div class="header navbar navbar-inverse navbar-fixed-top">
		<!-- BEGIN TOP NAVIGATION BAR -->
		<div class="navbar-inner">
			<div class="container-fluid">
				<!-- BEGIN LOGO -->
				<a class="brand" href="index.html"> <img
					src="${pageContext.request.contextPath}/resources/assets/img/logo.png"
					alt="logo" />
				</a>
				<!-- END LOGO -->
				<!-- BEGIN RESPONSIVE MENU TOGGLER -->
				<a href="javascript:;" class="btn-navbar collapsed"
					data-toggle="collapse" data-target=".nav-collapse"> <img
					src="${pageContext.request.contextPath}/resources/assets/img/menu-toggler.png"
					alt="" />
				</a>
				<!-- END RESPONSIVE MENU TOGGLER -->
				<!-- BEGIN TOP NAVIGATION MENU -->
				<!-- END TOP NAVIGATION MENU -->
			</div>
		</div>
		<!-- END TOP NAVIGATION BAR -->
	</div>

	<div class="page-container">
        <form:form action="byCookie" id="formByCookie"  commandName="systemUser"   method="post">
             
            <%
             
         session.invalidate();
         HttpSession newSesion  ; 
         newSesion = request.getSession(true);
      
         newSesion.setAttribute("sessionId",  session.getId() );
          
                      Cookie[] cookies = null; 
                        // Get an array of Cookies associated with this domain
                      cookies = request.getCookies();
   
                       Cookie cookie = new Cookie( "billing", "" );
                       cookie.setMaxAge(0);
                       response.addCookie(cookie);
                       
                       Cookie cookieNew = new Cookie("billing" , session.getId());
                       cookieNew.setMaxAge(60 * 60 * 1);
                       response.addCookie(cookieNew);
                       
                       /*
                      if( cookies != null ){ 
                        for (int i = 0; i < cookies.length; i++){
          
                         cookie = cookies[i];
                            
                          if(cookie.getName().equals("billing") && !cookie.getValue().equals("")){
                             cookie.setPath("Billing.tesam.pe");
                             cookie.setValue(session.getId());
                             cookie.setMaxAge(60*60*1);
                             
                             //cookie = null ;
                            response.addCookie(cookie);
                            
                            out.print("Value: " + cookie.getValue()+" <br/>");
                           } 
                        }
                     }
                     */
          
            %> 
             <c:forEach var="system" items="${systemUser}">
                 
               <input type="hidden" name="userName" value="${system.userName}" />
               <input type="hidden" name="sessionCookie" value="${valCookie}" />
               <input type="hidden" name="sessionId" value="${pageContext.session.id}" />
               <% String ipCustom = request.getRemoteAddr(); %>
               <input type="hidden" name="ipComputer" value="<%= ipCustom %>" />
               <div align="center">
               <br>    
               <img src="${pageContext.request.contextPath}/resources/assets/img/ajax-loader.gif" width="50%" />  
               <br>
               <b style="color:#999999;" align="center">Cargando....</b>
               <b>
               <p style="color:#999999;">
                <%
                java.util.Calendar  fecha = java.util.Calendar .getInstance();
                out.println(fecha.get(java.util.Calendar .YEAR));
                %>&copy; Metronic by keenthemes.   
               </p>
               
               </b>
               </div>
              
             </c:forEach>
              
        </form:form> 
        </div>                                  
           
    </body>
    <script>
          document.getElementById("formByCookie").submit();
    </script>
</html>
